package com.zrt.pad.commonui;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.util.Log;

public class PromptWindow {
	private AlertDialog.Builder dialogBuilder;
	
	public PromptWindow(Context context, String string) {
		dialogBuilder = new AlertDialog.Builder(context);
		
		if ("同步失败！" == string) {
			dialogBuilder.setTitle("失败");
			dialogBuilder.setMessage("同步失败！");
		} else if ("网络未连接！" == string) {
			dialogBuilder.setTitle("失败");
			dialogBuilder.setMessage("网络未连接！");
		} else {
			dialogBuilder.setTitle("失败");
			dialogBuilder.setMessage("错误: " + string);
		}
		
		dialogBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				Log.i("TAG", "你点击的是确定");
			}
		});
		
		dialogBuilder.setCancelable(false);
	}
	
	public PromptWindow(Context context, int timeComparison) {
		dialogBuilder = new AlertDialog.Builder(context);
		
		if (1 == timeComparison) {
			dialogBuilder.setTitle("错误");
			dialogBuilder.setMessage("营业时间不能小于日结日期！");
		} else if (2 == timeComparison) {
			dialogBuilder.setTitle("错误");
			dialogBuilder.setMessage("营业时间不能等于日结日期！");
		} else if (-2 == timeComparison) { 
			dialogBuilder.setTitle("错误");
			dialogBuilder.setMessage("营业时间不能超过日结日期后第14天！");
		}else {
			dialogBuilder.setTitle("错误");
			dialogBuilder.setMessage("未知错误！");
		}
		
		dialogBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				Log.i("TAG", "你点击的是确定");
			}
		});
		
		dialogBuilder.setCancelable(false);
	}

	public void showDialog(){
		dialogBuilder.show();
	}
}
